package com.example.base;

import java.util.Date;

public class Main {
    //类常量
    public static final double CM_PER_INCH = 2.54;
    enum Size {
        SMALL,
        MEDIUM,
        LARGE,
        EXTRA_LARGE
    }
    public static void main(String[] args) {
        double paperWidth  = 8.5;
        double paperHeight = 11;
        System.out.println("Paper size in centimeters: "
        + paperWidth * CM_PER_INCH + " by " + paperHeight * CM_PER_INCH);
        Size size = Size.LARGE;
        System.out.println(size);

        double x = 4;
        double y = Math.sqrt(x);
        System.out.println(y);//2.0
        System.out.println(Math.PI);

        int n = 123456789;
        float a = (int)n;
        System.out.println(a);//1.23456792E8

        double x2 = 9.997;
        int nx = (int)Math.round(x2);
        System.out.println(nx);//10

        int x3 = 300;
        byte nx3 = (byte)x3;
        System.out.println(nx3);//44

        int x4 = 1;
        x4 += 3.5;
        System.out.println(x4);//4

        int x5 = 9;
        int fourthBitFromRight = (x5 & 0b1000) / 0b1000;
        System.out.println(fourthBitFromRight);//1

        var b = 12;
        System.out.println(b);//12

        String all = String.join(" / ", "S", "M", "L", "XL");
        System.out.println(all);

        String repeated = "Java".repeat(3);
        System.out.println(repeated);


        String greeting = "Hello";
        int index = greeting.offsetByCodePoints(0, 1);
        int cp = greeting.codePointAt(index);
        System.out.println(index);//1
        System.out.println(cp);//101, e 的 ascii 码

        int cpCount = greeting.codePointCount(0, greeting.length());
        System.out.println("码点的数量：" + cpCount);//5

        System.out.printf("%tc", new Date());//Sun Nov 28 17:31:31 CST 2021
    }
}
